package one;

import java.util.Arrays;

public class BenchMarkDemo {
   public static void main(String[] args) {
	System.out.println(generate(10000000)+"豪秒");
}
	public static double generate(int max) {//埃拉托色尼质数过滤算法
		long start = System.currentTimeMillis();
		boolean sieve[] = new boolean[max];
		Arrays.fill(sieve, true);
		sieve[0] = false;
		sieve[1] = false;
		for (int i = 2; i < Math.sqrt(max); i++) {
			if (sieve[i]) {
				for (int j = 2 * i; j < sieve.length; j += i) {
					sieve[j] = false;
				}
			}
		}
		return (System.currentTimeMillis() - start) ;
	}
}
